package Work2;

import java.util.ArrayList;
import java.util.Iterator;

/*
 *@Student 张策
 */
public class Main {
    public static void main(String[] args) {
        Car car1 = new Car("宝马", 400000);
        Car car2 = new Car("宾利", 600000);
        ArrayList list=new ArrayList();
        ArrayList list2=new ArrayList();
        list.add(car1);
        list.add(car2);
//        list.remove(0);
//        list.contains(car2);
//        System.out.println(list.size());
//        System.out.println(list.isEmpty());
//        list.clear();
//        list.addAll();
//        System.out.println(list.contains(6));
//        list.removeAll(list);
//        System.out.println(list);
        for (Object object :list) {
            System.out.println(object);
        }
        Iterator iterator=list.iterator();
        while (iterator.hasNext()) {
            Object next =  iterator.next();
            System.out.println(next );
        }
    }
}
class Car{
    private String name;
    private int price;

    public Car(String name, int price) {
        this.name = name;
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Car{" +
                "name='" + name + '\'' +
                ", price=" + price +
                '}';
    }
}
